package com.ymatou.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.userservice.parameter.SellerOnlineStatusRequestBean;
import com.ymatou.userservice.service.SellerOnlineStatusRequestCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.UserCallService;
import com.ymttest.database.sqlwapper.UserSafeWapper;
import com.ymttest.utils.YMTDateUtil;
/**
*查询买手在线状态
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SellerOnlineStatusRequest{
	private static SellerOnlineStatusRequestBean selleronlinestatusrequestBean;
	private static SellerOnlineStatusRequestCall selleronlinestatusrequestCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询买手在线状态");
	}

	@Before
	public void caseUp() {
		selleronlinestatusrequestBean=new SellerOnlineStatusRequestBean();
		selleronlinestatusrequestCall=new SellerOnlineStatusRequestCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(selleronlinestatusrequestCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_001() {
		Logger.start(true,"买手账号PC客服后台设置,为在线,PCIMChangStatus10001:1,查询出状态为在线");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "10001", "1");
			UserCallService.setOnlineStatusOp(userId, "10002", "1");
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("online", selleronlinestatusrequestCall.getStatus(), "验证online");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_002() {
		Logger.start(true,"开启接收买手咨询消息AppReceiveMsgOp20001:1且买手APP认证服务TOKEN认证开启AppTokenAuth30001:optime15分钟内,查询出状态为在线");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "20001", "1");
			UserCallService.setOnlineStatusOp(userId, "30001", "1");
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("online", selleronlinestatusrequestCall.getStatus(), "验证online");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_003() {
		Logger.start(true,"开启接收买手咨询消息AppReceiveMsgOp20001:1且手机前台运行AppRunType40001:1,查询出状态为在线");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "20001", "1");
			UserCallService.setOnlineStatusOp(userId, "40001", "1");
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("online", selleronlinestatusrequestCall.getStatus(), "验证online");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_004() {
		Logger.start(true,"买手登出PCIMChangStatus10002:0且没开启接收买手咨询消息AppReceiveMsgOp20001:0且2小时没有token认证AppTokenAuth30001:optime超过当前2小时,查询出状态为离线");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "10002", "0");
			UserCallService.setOnlineStatusOp(userId, "20001", "0");
			UserCallService.setOnlineStatusOp(userId, "30001", "0",YMTDateUtil.getBeforeOrNextDay(-1));
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("offline", selleronlinestatusrequestCall.getStatus(), "验证offline");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_005() {
		Logger.start(true,"买手隐身PCIMChangStatus10001:0,查询出状态为离开");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "10001", "0");
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("leave", selleronlinestatusrequestCall.getStatus(), "验证leave");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_006() {
		Logger.start(true,"开启接收买手咨询消息AppReceiveMsgOp	20001:1且接受push消息ppReceiveMsgOp	20002:1且2小时没有token认证AppTokenAuth30001:optime超过当前2小时,查询出状态为离开");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "20001", "1");
			UserCallService.setOnlineStatusOp(userId, "20002", "1");
			UserCallService.setOnlineStatusOp(userId, "30001", "0",YMTDateUtil.getBeforeOrNextMunite(-125));
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("leave", selleronlinestatusrequestCall.getStatus(), "验证leave");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_007() {
		Logger.start(true,"开启接收买手咨询消息AppReceiveMsgOp20001:1且不接受push消息ppReceiveMsgOp20001:0且15分钟内没有token认证AppTokenAuth30001:optime超过当前15分钟,查询出状态为离开");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "20001", "1");
			UserCallService.setOnlineStatusOp(userId, "20002", "0");
			UserCallService.setOnlineStatusOp(userId, "30001", "0",YMTDateUtil.getBeforeOrNextMunite(-20));
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("leave", selleronlinestatusrequestCall.getStatus(), "验证leave");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_008() {
		Logger.start(true,"买手登出PCIMChangStatus10002:0且没登入appAppLoginStatus50001:0且2小时没有token认证AppTokenAuth30001:optime超过当前2小时,查询出状态为离线");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "10002", "0");
			UserCallService.setOnlineStatusOp(userId, "50001", "0");
			UserCallService.setOnlineStatusOp(userId, "30001", "0",YMTDateUtil.getBeforeOrNextMunite(-135));
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("offline", selleronlinestatusrequestCall.getStatus(), "验证offline");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerOnlineStatusRequest_009() {
		Logger.start(true,"买手登出PCIMChangStatus10002:0且没启接收买手咨询消息AppReceiveMsgOp20001:0且2小时没有token认证AppTokenAuth30001:optime超过当前2小时,查询出状态为离线");
		try {
			Integer userId=94;
			new UserSafeWapper().deleteSellerOnlineStatus(userId);
			UserCallService.setOnlineStatusOp(userId, "10002", "0");
			UserCallService.setOnlineStatusOp(userId, "20001", "0");
			UserCallService.setOnlineStatusOp(userId, "30001", "0",YMTDateUtil.getBeforeOrNextMunite(-135));
			selleronlinestatusrequestBean.setUserId(userId);
			selleronlinestatusrequestCall.setData(selleronlinestatusrequestBean);
			selleronlinestatusrequestCall.callService();
			Logger.verifyEquals("offline", selleronlinestatusrequestCall.getStatus(), "验证offline");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}